<?PHP

	include("../includes/configPages.php");
	include("../includes/forum/topic.class.php");
	include("../includes/forum/post.class.php");
	$topic = new topic();
	$post = new post();

	$outHtml = "";
	
	$newsBoard = $config->getVal($db, 'news_board');
	$newsLimit = $config->getVal($db, 'news_limit');
	$topicRes = $topic->getAllTopics($db, $newsBoard, $newsLimit, 1);
	$variableStack['news_list']="";
	if(mysql_num_rows($topicRes)==0){
		$variableStack['news_list']="No news";
	} else {
		while($row = mysql_fetch_object($topicRes)){
			$postRes = $post->getPost($db, $row->topic_first_post_id);
			if(mysql_num_rows($postRes)==0){
				$variableStack['news_list']="News permission error. Please contact an adminitrator";	
			} else {
				$artHtml = file_get_contents('../styles/'.$activeStyle.'/t/main-article.html');
				$artVariableStack['title']=mysql_result($postRes,0,'post_name');
				$artVariableStack['content']=mysql_result($postRes,0,'post_content_html');
				$artVariableStack['time'] = date('r', mysql_result($postRes,0,'post_time'));
				$artVariableStack['replies'] = $row->topic_replies;
				$artVariableStack['views'] = $row->topic_views;
				$artVariableStack['topic_id'] = $row->topic_id;
				$variableStack['news_list'] .= parseHtml($artHtml, $artVariableStack);
			}
		}
	}
	$variableStack['board_id']=	$newsBoard;	
	$html = file_get_contents('../styles/'.$activeStyle.'/t/main.html');
	echo parseHtml($html, $variableStack);
	
?>